<?php
/**
 * 测试类
 * User: Sanit
 * Date: 2017/3/6
 * Time: 23:24
 */

use Sanit\Validator\Factory;

class TestValidator
{
    protected $validate;

    public function __construct()
    {
        $this->validate = new Factory();
    }

    public function test($data,$rules=[],$errors=[])
    {
        $validator  = $this->validate->make($data,$rules,$errors);
        if($validator->passes()){

        }else{
            var_dump($validator->errors()->all());
        }
    }
}
$test = new TestValidator();
$data = [
    'username' => 'test_test',
    'password' => 'password'
];
$rules = [
    'username' => 'required|min:5',
    'password' => 'confirmed',
];
$errors = [
    'require' => '字段 :attribute 不能为空 '
];
$test->test($data,$rules,$errors);